import java.util.Scanner;

public class FrobeniusCoinProblem {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入第一种金币的面值（正整数）：");
        int a = scanner.nextInt();
        System.out.print("请输入第二种金币的面值（正整数）：");
        int b = scanner.nextInt();
        if (gcd(a, b) != 1) {
            System.out.println("输入的金币面值不是互素的，请重新输入。");
        } else {
            int result = (a - 1) * (b - 1) - 1;
            System.out.println("无法准确支付的最大价值为: " + result + " 金币");
        }

        scanner.close();
    }
    public static int gcd(int x, int y) {
        while (y != 0) {
            int temp = y;
            y = x % y;
            x = temp;
        }
        return x;
    }
}
